(function (){
	const cryKEY = CryptoJS.enc.Utf8.parse('qbCfDb2xJnJGA6tK'); // 替换成申请到的secret
	const cryIV = CryptoJS.enc.Utf8.parse('78783402efb164ad'); // 注意，该值不用变

	Crypto = {
		UUID:function(){
			let len = 32;
			let chars = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";
			let maxPos = chars.length;
			let character = "";
			for (let i = 0; i < len; i++) {
				character += chars.charAt(Math.floor(Math.random() * maxPos));
			}
			return character;
		},
		/**
		 * 加密
		 * @param {*} word
		 * @param {*} keyStr
		 * @param {*} ivStr
		 */
		encrypt:function(word, keyStr, ivStr) {
		    let key = cryKEY;
		    let iv = cryIV;
		    if (keyStr) {
		      key = CryptoJS.enc.Utf8.parse(keyStr);
		      iv = CryptoJS.enc.Utf8.parse(ivStr);
		    }
		    let srcs = CryptoJS.enc.Utf8.parse(word);
		    var encrypted = CryptoJS.AES.encrypt(srcs, key, {
		      iv: iv,
		      mode: CryptoJS.mode.CBC,
		      padding: CryptoJS.pad.ZeroPadding
		    });
		    return CryptoJS.enc.Base64.stringify(encrypted.ciphertext);
		 },
		 /**
		   * 解密
		   * @param {*} word
		   * @param {*} keyStr
		   * @param {*} ivStr
		   */
		 decrypt:function(word, keyStr, ivStr) {debugger;
		    let key = cryKEY;
		    let iv = cryIV;

		    if (keyStr) {
		      key = CryptoJS.enc.Utf8.parse(keyStr);
		      iv = CryptoJS.enc.Utf8.parse(ivStr);
		    }

		    let base64 = CryptoJS.enc.Base64.parse(word);
		    let src = CryptoJS.enc.Base64.stringify(base64);

		    let decrypt = CryptoJS.AES.decrypt(src, key, {
		      iv: iv,
		      mode: CryptoJS.mode.CBC,
		      padding: CryptoJS.pad.ZeroPadding
		    });

		    let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
		    return decryptedStr.toString();
		 }
	}
});